

from playwright.sync_api import sync_playwright


with sync_playwright() as p:
    browser = p.chromium.launch(headless=False)
    page = browser.new_page()
    page.goto('https://www.baidu.com')
    page.wait_for_timeout(2000)
    # page.locator('//*[@id="kw"]').focus()

    # page.locator('//*[@id="kw"]').press('python')
    page.locator('//*[@id="kw"]').fill('python01')
    page.locator('//*[@id="kw"]').press('Control+A')
    page.wait_for_timeout(2000)
    page.locator('//*[@id="kw"]').press('Backspace')
    # page.locator('#kw').press('Contr0l+A')
    # page.locator('#kw').press('python')


    page.wait_for_timeout(2000)

